﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using WcfServer.Classes.Server;
using WcfServer.Classes.Utility;

namespace Client
{
    /// <summary>
    /// Interaction logic for SignUp.xaml
    /// </summary>
    public partial class SignUp : Page
    {
        public SignUp()
        {
            InitializeComponent();
        }

        private void SignupAction(object sender, RoutedEventArgs e)
        {
            var connection = new Client.ServerService.ServerServiceClient();
            SignUpUserInfo req = new SignUpUserInfo()
            {
                Avatar=null,
                FirstName = FN.Text,
                LastName= LN.Text,
                UserID = UN.Text,
                Password = EncryptionHandler.HashSHA256(Encoding.UTF8.GetBytes(PW.Password))
            };
            //public_key server
            String result = connection.SignUp(req.Prepare(File.ReadAllText(@"server_public.xml")));
            
            res.Content = result;
        }

        private void GoBack(object sender, RoutedEventArgs e)
        {
            if (this.NavigationService.CanGoBack)
                this.NavigationService.GoBack();
        }

    }
}
